<include file="Common:header" />
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css"  rel="stylesheet" href="__PUBLIC__/uploadify/uploadify.css">
<style type="text/css">
    .edui-default{line-height:20px;}
    div.edui-combox-body,div.edui-button-body,div-edui-splitbutton-body{overflow:hidden;height:20px}
    div.edui-box{overflow:hidden;height:22px}
    .uploadify{display:inline-block;}
    .uploadify-button{border:none;border-radius:5px;margin-top:8px;}
    table.add_tab tr td span.uploadify-button-text{color:#FFF;margin:0;}
    #art_thumb_img{max-height: 130px;max-width: 500px;margin-top: 10px;}
    .list_upload {overflow: hidden;    }
    .list_upload li{float:left;margin: 0px 20px;}
    #some_file_queue{display: none}
</style>
</head>
<body>
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i><a href="{:U(MODULE_NAME.'/Index/info')}"> 首页</a> &raquo; 添加产品
</div>
<!--面包屑导航 结束-->

<!--TAB切换面板和外置按钮组 开始-->
<div class="result_wrap">
    <div class="result_title">
        <h3>快捷操作</h3>

    </div>
    <div class="result_content">
        <div class="short_wrap">
            <a href="{:U(MODULE_NAME.'/Product/add')}"><i class="fa fa-plus"></i>新增产品</a>
            <a href="{:U(MODULE_NAME.'/Product/index')}"><i class="fa fa-refresh"></i>刷新页面</a>
        </div>
    </div>
</div>

<div class="result_wrap">
    <ul class="tab_title">
        <li class="active">基本信息</li>
        <li>商品图集</li>
        <notempty name="field">
        <li>商品参数</li>
        </notempty>
        <li>详细描述</li>
        <li>售后服务</li>
    </ul>
    <form action="{:U(MODULE_NAME.'/Product/add')}" method="post">
    <div class="tab_content">

        <table class="add_tab">
            <tbody>
            <tr>
                <th width="120"><i class="require">*</i>产品分类：</th>
                <td>
                    <select name="cate_id">
                        <foreach name="cate" item="v">
                            <option value="{$v.cate_id}">{$v._cate_name}</option>
                        </foreach>
                    </select>
                </td>
            </tr>
            <tr>
                <th><i class="require">*</i>产品标题：</th>
                <td>
                    <input type="text" class="lg" id="pro_title" name="pro_title"> <a href="javascript:void(0)" id="checkNewsTitle">检测是否重复</a>
                </td>
            </tr>
            <tr>
                <th>作者：</th>
                <td><input type="text" name="pro_editor" value="{$Think.session.username}"></td>
            </tr>
            <tr>
                <th>产品关键词：</th><td><input type="text" class="lg" name="pro_tag">多关键词间用半角逗号（,）分开，可用于做文章关联阅读条件</td>
            </tr>
            <tr>
                <th>产品描述：</th>
                <td><textarea name="pro_description"></textarea>用于SEO的description</td>
            </tr>
            <tr>
                <th width="120">产品价格</th>
                <td><input type="text" size="20" id="pro_price" name="pro_price"></td>
            </tr>
            <tr>
                <th width="120">产品型号</th>
                <td><input type="text"  size="20"  id="pro_sn" name="pro_sn"></td>
            </tr>
            </tbody>
        </table>


    </div>
    <div class="tab_content">

        <div class="result_wrap">
            <ul class="list_pic">
                <li><img id="pic_1" src="__PUBLIC__/images/none_150.jpg" style="width:150px;height: 150px"><span onclick="del_pic(1)"><i class="fa fa-ban"></i></span><input type="hidden" id="pro_thumb1" name="pro_thumb1"/> </li>
                <li><img id="pic_2" src="__PUBLIC__/images/none_150.jpg" style="width:150px;height: 150px"><span onclick="del_pic(2)"><i class="fa fa-ban"></i></span><input type="hidden" id="pro_thumb2" name="pro_thumb2"/></li>
                <li><img id="pic_3" src="__PUBLIC__/images/none_150.jpg" style="width:150px;height: 150px"><span onclick="del_pic(3)"><i class="fa fa-ban"></i></span><input type="hidden" id="pro_thumb3" name="pro_thumb3"/></li>
            </ul>

            <ul class="list_upload">
                <li><input id="file_upload1" name="file_upload1" type="file" multiple="true"></li>
                <li><input id="file_upload2" name="file_upload2" type="file" multiple="true"></li>
                <li><input id="file_upload3" name="file_upload3" type="file" multiple="true"></li>
            </ul>
        </div>

    </div>
        <notempty name="field">
    <div class="tab_content">
        <table class="add_tab">
            <foreach name="field" item="v">
            <tr>
                <th width="120">{$v.field_title}：</th>
                <td>{$v._html}</td>
            </tr>
            </foreach>
        </table>
        <div class="tips" style="margin-top: 15px;">
            <h3>商品参数添加问题</h3>
            <p>1、如果商品字段参数不够用请到<a href="{:U(MODULE_NAME.'/FieldProduct/index')}">产品模型</a>中添加；</p>
        </div>
    </div>
            </notempty>
    <div class="tab_content">
        <script id="editor" name="pro_content" id="pro_content" type="text/plain" style="width:850px;height:300px;"></script>

    </div>
    <div class="tab_content">
        <script id="saleserver" name="pro_sale" id="pro_sale" type="text/plain" style="width:850px;height:300px;"></script>
    </div>

    <div class="btn_group">
        <input type="submit" id="button" value="提交">
        <input type="button" class="back" onclick="history.go(-1)" value="返回" >
    </div>
    </form>

</div>
<!--TAB切换面板和外置按钮组 结束-->
<script type="text/javascript">
    //删除图片列表
    function del_pic(num){
        $('#pic_'+num).attr('src','__PUBLIC__/images/none_150.jpg');
        $('#pro_thumb'+num).attr('value','');
    }

    var sid = '{:session_id()}';
    //实例化编辑器
    var ue = UE.getEditor('editor', {
        //serverUrl: '/server/ueditor/controller.php'
    });
    var ue = UE.getEditor('saleserver', {
        //serverUrl: '/server/ueditor/controller.php'
    });
    $(function() {

        $('#file_upload1').uploadify({
            'queueID'  : 'some_file_queue',
            'buttonText' : '缩略图上传',
            'formData'     : {'timestamp' : '<?php echo time();?>','session_id' : sid},
            'swf'      : "__PUBLIC__/uploadify/uploadify.swf",
            'uploader' : "{:U(MODULE_NAME.'/Upload/uploadify')}",
            "onUploadSuccess" : uploadPicture1
        });
        //可以根据自己的要求来做相应处理
        function uploadPicture1(file, data){
            var data = $.parseJSON(data);
            var src = '';
            if(data.status){
                $('input[name=pro_thumb1]').val(data.info);
                $('#pic_1').attr('src','__ROOT__/Uploads/thumb/'+data.info);
            } else {
                alert(data.info);
            }
        }

        $('#file_upload2').uploadify({
            'queueID'  : 'some_file_queue',
            'buttonText' : '缩略图上传',
            'formData'     : {'timestamp' : '<?php echo time();?>','session_id' : sid},
            'swf'      : "__PUBLIC__/uploadify/uploadify.swf",
            'uploader' : "{:U(MODULE_NAME.'/Upload/uploadify')}",
            "onUploadSuccess" : uploadPicture2
            /*'onUploadSuccess' : function(file, data, response) {
                if(response){
                    $('input[name=pro_thumb2]').val(data);
                    $('#pic_2').attr('src','__ROOT__/Uploads/thumb/'+data);
                }

            }*/
        });
        //可以根据自己的要求来做相应处理
        function uploadPicture2(file, data){
            var data = $.parseJSON(data);
            var src = '';
            if(data.status){
                $('input[name=pro_thumb2]').val(data.info);
                $('#pic_2').attr('src','__ROOT__/Uploads/thumb/'+data.info);
            } else {
                alert(data.info);
            }
        }


        $('#file_upload3').uploadify({
            'queueID'  : 'some_file_queue',
            'buttonText' : '缩略图上传',
            'formData'     : {'timestamp' : '<?php echo time();?>','session_id' : sid},
            'swf'      : "__PUBLIC__/uploadify/uploadify.swf",
            'uploader' : "{:U(MODULE_NAME.'/Upload/uploadify')}",
            "onUploadSuccess" : uploadPicture3
        });

        //可以根据自己的要求来做相应处理
        function uploadPicture3(file, data){
            var data = $.parseJSON(data);
            var src = '';
            if(data.status){
                $('input[name=pro_thumb3]').val(data.info);
                $('#pic_3').attr('src','__ROOT__/Uploads/thumb/'+data.info);
            } else {
                alert(data.info);
            }
        }


        $("#checkNewsTitle").click(function(){
            if($('#pro_title').val()==''){
                layer.msg('标题不能为空！');
                return false;
            }
            $.getJSON("{:U(MODULE_NAME.'/Product/checkProductTitle')}", { pro_title:$("#pro_title").val(),pro_id:"{$info.pro_id}"}, function(json){
                $("#checkNewsTitle").css("color",json.status==1?"#8c21ad":"#f81f3e").html(json.info);
            });
        });


        $("#button").click(function() {
            var pro_title = $("#pro_title").val();
            var pro_content = $('textarea[name=pro_content]').val();
            if(pro_title == ''){
                layer.msg('产品标题不能为空！');
                $("#pro_title").focus();
                return false;
            }
            if(pro_content ==null ){
                layer.msg('产品描述不能为空！');
                return false;
            }
        });
    });
</script>
</body>
</html>